//
//  UINavigationBar+YFExtension.m
//  project
//
//  Created by yefei on 2019/5/6.
//  Copyright © 2019 健健. All rights reserved.
//

#import "UINavigationBar+YFExtension.h"

@implementation UINavigationBar (YFExtension)

- (void)gradientBackground:(UIColor *)color textColor:(UIColor *)textColor offsetY:(CGFloat)offsetY critical:(CGFloat)critical {
    // 计算透明度
    CGFloat alpha = 0;
    if (offsetY > critical * 0.5) {
        alpha = (offsetY - critical) / critical * 0.5  > 1.f ? 1 : (offsetY - critical) * 0.5;
    }
    [self setBackgroundImage:[color withAlphaComponent:alpha].image forBarMetrics:(UIBarMetricsDefault)];
    
}

@end
